#include "PE2_winec.h"

/*
 * @brief 
 * 私有化继承的方式中初始化使用代码中的方式
 * 因为没有包含关系里的类私有成员，所以需要直接通过私有化继承的类名直接初始化
 * 定义类公有函数时，需要使用私有类的数据也是类似的方法
 * 直接使用私有继承类名直接调用其成员进行输入输出
**/

using std::cout;
using std::cin;
using std::endl;

Wine::Wine(const char*l,int y,const int yr[],const int bot[])
    :PairArray(ArrayInt(yr,y),ArrayInt(bot,y)),name(l),years(y)
{}

Wine::Wine(const char*l,int y)
    :PairArray(ArrayInt(0),ArrayInt(0)),name(l),years(y)
{}

void  Wine::Show() const
{
    cout << "Wine:" << name << endl;
    cout << "\tYear\tBottles\n";
    for (int i = 0; i < years; ++i)
    {
        cout <<"\t"<<PairArray::year[i] << "\t" << PairArray::bottle[i] << endl;
    }
}

void  Wine::GetBottles(){
    PairArray::bottle.resize(years);
    PairArray::year.resize(years);
    cout << "Enter " << years << " data for " << name << endl;
    for (size_t i = 0; i < years; i++)
    {
        cout << "Enter year:";
        cin >> PairArray::year[i];
        cout << "Enter bottles for that year:";
        cin >> PairArray::bottle[i];
    }
}

std::string Wine::Label() const
{
    return name;
}

int Wine::sum() const
{
    return PairArray::bottle.sum();
}